<?php
namespace Bundle\FireIceBundle;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

class DynamicWorker implements \ArrayAccess
{
    private $_container;
    private $_eventDispatcher;

    /**
     * @var DynamicRouter
     */
    private $_dynamicRouter;

    /**
     * @var Cache
     */
    private $_cache;

    private $_controllerBuilder;

    public function __construct(ContainerInterface $container = null)
    {
        $this->_container = $container;

        $this->_eventDispatcher = new EventDispatcher();

        $this->_controllerBuilder = new ControllerBuilder($this);

        $this->_dynamicRouter = new DynamicRouter($this);

        $this->registerEventListeners();
    }

    public function getEventDispatcher()
    {
        return $this->_eventDispatcher;
    }

    protected function registerEventListeners()
    {
        $this->_eventDispatcher->connect('sitetree.node_updated', array($this->_dynamicRouter, 'nodeUpdated'));
        /// @TODO EventListeners
    }

    public function getRouter()
    {
        return $this->_dynamicRouter;
    }

    public function getControllerBuilder()
    {
        return $this->_controllerBuilder;
    }


}
